package net.xiangcaowuyu.quartztask.service;

import net.xiangcaowuyu.quartztask.entity.TaskQuartz;
import net.xiangcaowuyu.quartztask.mapper.TaskQuartzMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author laughing
 * @date 2020/9/30
 * @site https://www.lisen.org
 */
@Service
public class TaskQuartzServiceImpl implements TaskQuartzService {

    @Resource
    TaskQuartzMapper taskQuartzMapper;

    /**
     * 根据主键删除
     *
     * @param id 主键
     * @return 删除行数
     */
    @Override
    public int deleteByPrimaryKey(Long id) {
        return taskQuartzMapper.deleteByPrimaryKey(id);
    }

    /**
     * 插入
     *
     * @param record 实体
     * @return 成功返回1
     */
    @Override
    public int insert(TaskQuartz record) {
        return taskQuartzMapper.insert(record);
    }

    /**
     * 插入修改的值
     *
     * @param record 实体
     * @return 成功返回1
     */
    @Override
    public int insertSelective(TaskQuartz record) {
        return taskQuartzMapper.insertSelective(record);
    }

    /**
     * 根据主键获取
     *
     * @param id 主键
     * @return 实体
     */
    @Override
    public TaskQuartz selectByPrimaryKey(Long id) {
        return taskQuartzMapper.selectByPrimaryKey(id);
    }

    /**
     * 更新
     *
     * @param record 实体
     * @return 更新成功返回1
     */
    @Override
    public int updateByPrimaryKeySelective(TaskQuartz record) {
        return taskQuartzMapper.updateByPrimaryKeySelective(record);
    }

    /**
     * 更新所有值
     *
     * @param record 实体
     * @return 成功返回1
     */
    @Override
    public int updateByPrimaryKey(TaskQuartz record) {
        return taskQuartzMapper.updateByPrimaryKey(record);
    }

    /**
     * 根据名称及分组查找
     *
     * @param jobName  任务名称
     * @param jobGroup 任务分组
     * @return 任务
     */
    @Override
    public TaskQuartz selectByJobNameAndJobGroup(String jobName, String jobGroup) {
        return taskQuartzMapper.selectByJobNameAndJobGroup(jobName,jobGroup);
    }

    /**
     * 根据名称及分组查找
     *
     * @param jobName  任务名称
     * @param jobGroup 任务分组
     * @return 任务
     */
    @Override
    public int deleteByJobNameAndJobGroup(String jobName, String jobGroup) {
        return taskQuartzMapper.deleteByJobNameAndJobGroup(jobName,jobGroup);
    }
}
